import React from 'react';
import { connect } from 'react-redux';
import { addTodo } from '../actions';

var AddTodo = function AddTodo(_ref) {
  var dispatch = _ref.dispatch;

  var input = void 0;

  return React.createElement(
    'div',
    null,
    React.createElement(
      'form',
      {
        onSubmit: function onSubmit(e) {
          e.preventDefault();
          if (!input.value.trim()) {
            return;
          }
          dispatch(addTodo(input.value));
          input.value = '';
        }
      },
      React.createElement('input', {
        ref: function ref(node) {
          input = node;
        }
      }),
      React.createElement(
        'button',
        { type: 'submit' },
        'Add Todo'
      )
    )
  );
};
AddTodo = connect()(AddTodo);

export default AddTodo;